package com.cookie.libnetwork;

import java.util.Map;

import okhttp3.FormBody;

/**
 * 项目名:    CookieJoke
 * 包名:      com.cookie.libnetwork
 * 文件名:    PostRequest
 * 创建者:    cookie
 * 创建时间:   2020/2/29 0:11
 * 描述:      TODO
 */

public class PostRequest<T> extends Request<T,PostRequest> {

    public PostRequest(String url) {
        super(url);
    }

    @Override
    protected okhttp3.Request generateRequest(okhttp3.Request.Builder builder) {
        FormBody.Builder bodyBuilder = new FormBody.Builder();
        for (Map.Entry<String, Object> entry : params.entrySet()) {
            bodyBuilder.add(entry.getKey(), (String) entry.getValue());
        }
        okhttp3.Request request = builder.url(mUrl).post(bodyBuilder.build()).build();
        return request;
    }
}
